﻿using FormsAuthWeb.Models;
using FormsAuthWeb.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FormsAuthWeb
{
    public partial class Message : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        /// <summary>
        /// 获取用户信息列表
        /// </summary>
        /// <returns></returns>
        public string GetUserInfoList()
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("<li class='list-group-item'>当前用户登录名：{0}</li>", HttpUtility.HtmlEncode(Context.User.Identity.Name));
            builder.AppendFormat("<li class='list-group-item'>IsAuthenticated：{0}</li>", Request.IsAuthenticated);
            builder.AppendFormat("<li class='list-group-item'>登录用户的类型：{0}</li>", Context.User.GetType().ToString());
            builder.AppendFormat("<li class='list-group-item'>登录用户的身份标识对象类型：{0}</li>", Context.User.Identity.GetType().ToString());
            FormsPrincipal<UserInfo> user = Context.User as FormsPrincipal<UserInfo>;
            if (user != null)
            {
                builder.AppendFormat("<li class='list-group-item'><strong>登录用户的自定义数据：</strong>{0}</li>", HttpUtility.HtmlEncode(user.UserData.ToString()));
            }
            return builder.ToString();
        }
    }
}